<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
<title></title>
</head>
<body>
<p id="div"></p>
<script type="text/javascript">
    var xmldoc, txt = "";
    var text = "<goods>" +
        "<goodsname>OPPO R15</goodsname>" +
        "<pinpai>OPPO</pinpai>" +
        "<price>2000</price>" +
        "</goods>";
    if (window.DOMParser){
        parser=new DOMParser();
        xmldoc=parser.parseFromString(text,"text/xml");
    }else{ // Internet Explorer
        xmldoc=new ActiveXObject("Microsoft.XMLDOM");
        xmldoc.async=false;
        xmldoc.loadXML(txt);
    }
    var x = xmldoc.documentElement.childNodes;
    for (var i = 0; i < x.length ;i++) {
        txt += x[i].nodeName + "：" + x[i].childNodes[0].nodeValue + "<br>";
    }
    document.getElementById("div").innerHTML = txt;
</script>
</body>
</html>
